package com.projet.segmiMap.activities;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.projet.segmiMap.R;

/**
 * Created with IntelliJ IDEA.
 * User: Philippe
 * Date: 07/12/13
 * Time: 17:20
 * To change this template use File | Settings | File Templates.
 */
public class TestActivity extends FragmentActivity {
    public SlidingMenu getSlidingMenu() {
        return slidingMenu;
    }

    private SlidingMenu slidingMenu;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setTitle("yo");
        slidingMenu = new SlidingMenu(this);
        slidingMenu.setMode(SlidingMenu.LEFT);
        slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
        slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        slidingMenu.setFadeDegree(0.35f);
        slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        slidingMenu.setMenu(R.layout.slidingmenu);
        if (android.os.Build.VERSION.SDK_INT >= 11)
            getActionBar().setDisplayHomeAsUpEnabled(true);
        RelativeLayout b = (RelativeLayout) findViewById(R.id.menu);
        b.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                getSlidingMenu().toggle();
            }
        });
        View.OnClickListener changeEtage = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Context c = getApplicationContext();
                int id = v.getId();
                Button button = (Button) findViewById(id);
                String message = button.getText().toString();
                Toast t = Toast.makeText(c, message, Toast.LENGTH_LONG);
                t.show();
            }

        };
        //Button b1=(Button) findViewById(R.id.button2);
        //     b1.setOnClickListener(changeEtage);
    }

    @Override
    public void onBackPressed() {
        if (slidingMenu.isMenuShowing()) {
            slidingMenu.toggle();
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            this.slidingMenu.toggle();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


}
